from fastapi import FastAPI, APIRouter
from fastapi.staticfiles import StaticFiles
from amis import Page, App, Service, Markdown
from starlette.responses import HTMLResponse
from frame import PageApp
from api import TestModel, router

app = PageApp()
js_dir = "default_template"
app.register_public()  # 注册静态资源
js_root_path = "/default_template"
app.register_js(js_root_path, directory=js_dir)  # 注册所有的js 配置
app.register_amis_static_forward()  # 对本项目中得静态资源进行amis转换
# 注册登录页面
app.register_page("/login", js_url=js_root_path + "/login.js")
# todo:其他自定义页面自行添加

# 注册后台页面
app.register_admin_app("/", js_admin_router_url=js_root_path + "/router.json", brandName="测试Demo")
app.register_middleware()

# 添加接口路由组
app.include_router(router)

if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=9000)
